package io;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class ReadAndWriteLine {
	public static void main(String args[]){
		File filein = new File("file/textin.txt");
		File fileout = new File("file/textout.txt");
		try {
			FileReader fin = new FileReader(filein);
			FileWriter fout = new FileWriter(fileout);
			BufferedReader in = new BufferedReader(fin);
			BufferedWriter out = new BufferedWriter(fout);
			String line = "";
			while((line=in.readLine())!=null){
				System.out.println(line);
				if(line.equals("\n"))
					out.newLine();
				out.write(line);
				out.newLine();
			}
			in.close();
			System.out.println("Dữ liệu đã được lưu ra file: "+fileout.getName());
			out.close();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
}
